<div class="SipeiInfo pt20"><!--阅卷准备_03理员任务维护_编辑-->
    <?php
    $form = $this->beginWidget('CActiveForm', array(
    'action' => $this->createUrl('/problem/question/questionadd'),
    'method' => 'POST',
    'id' => 'add_form',
    'htmlOptions' => array('target' => 'ajax-frame')
    ));
    ?>   
    <?php
    $exam_id = isset($examinfo['exam_id']) ? $examinfo['exam_id'] : '';
    $subject_id = isset($subjectinfo['subject_id']) ? $subjectinfo['subject_id'] : '';
    ?>
    <table class="fontc_666 height32" width="100%"> 
        <tbody>
            <tr height="55">
                <td valign="top" width="110" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>所属考试项目：</td>
                <td valign="top" width="390" class="formValidator_td">
                    <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                        <span class="fl select_shelter">
                            <select class="fl fontc_666" name="exam_id" id="exam_id" onchange="checkexam(this.value)" >
                                <option value="0">请选择</option>
                                <?php if (!empty($exam)):foreach ($exam as $one): ?>
                                        <option value="<?php echo $one['exam_id']; ?>"><?php echo $one['exam_term_name']; ?></option>
                                        <?php
                                    endforeach;
                                endif;
                                ?>
                            </select>
                        </span>
                    </span>   
                    <div class="formValidator_tip">
                        <p id="exam_idTip" ></p>
                    </div> 
                </td>
            </tr>
            <tr height="55">
                <td valign="top" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>所属科目：</td>
                <td valign="top" class="formValidator_td">
                    <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                        <span class="fl select_shelter">
                            <select class="fl fontc_666" name="subject_id" id ="subject_id" onchange="checksubject(this.value);" >
                                <option value="0">请选择</option>
                                <?php if (!empty($subjectall)):foreach ($subjectall as $one): ?>
                                        <option value="<?php echo $one['subject_id']; ?>"><?php echo $one['subject_name']; ?></option>
                                        <?php
                                    endforeach;
                                endif;
                                ?>
                            </select>
                        </span>
                    </span> 
                    <div class="formValidator_tip">
                        <p id="subject_idTip" ></p>
                    </div> 
                </td>
            </tr>
            <tr height="55">
                <td valign="top" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>题号：</td>
                <td valign="top" class="formValidator_td">
                    <input type="text" name="num_id" id="num_id"  value="" class="col3 pt5 pr10 pb5 pl10 height20 border_c border_3 fontc_666">
                    <div class="formValidator_tip">
                        <p id="num_idTip" ></p>
                    </div> 
                </td>
            </tr>
            <tr height="55">
                <td valign="top" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>题型：</td>
                <td valign="top" class="formValidator_td">	
                    <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                        <span class="fl select_shelter">
                            <select class="fl fontc_666" name="num_type" id="num_type">
                            </select>
                        </span>
                    </span>
                    <div class="formValidator_tip">
                        <p id="num_typeTip" ></p>
                    </div>
                </td>
            </tr>
            <tr>
                <td valign="top" align="right" class="pr5">阅卷教师：</td>
                <td>
                    <div style="clear:both;" class="select_t_select">
                        <div class="dep_ben_list fl">
                            <div class="ben_title"></div>
                            <select multiple="" size="3" id="user_select" style="width:90px;height:150px;"></select>
                        </div>
                        <div class="dep_ben_btn fl"> 
                            <a href="javascript:;" class="right" style="display:block; margin:10px 5px; margin-top:40px;" ><img src="/themes/default/images/Sipei/btn_ben_right.gif" /></a> 
                            <a href="javascript:;" class="left" style="display:block; margin:10px 5px;""><img src="/themes/default/images/Sipei/btn_ben_left.gif" /></a> 
                        </div>
                        <div class="dep_ben_list fl">
                            <div class="ben_title"></div>
                            <select multiple="" size="3" id="userNameSelected" name="teacher_ids[]" style="width:90px;height:150px;"></select>
                        </div>
                        <div class="dep_ben_btn fl"> 
                            <a href="javascript:;" style="display:block; margin:0px 5px; color:black;" >组长：</a> 
                            <a href="javascript:;" class="right1" style="display:block; margin:10px 5px;" ><img src="/themes/default/images/Sipei/btn_ben_right.gif" /></a> 
                            <a href="javascript:;" class="left1" style="display:block; margin:10px 5px;""><img src="/themes/default/images/Sipei/btn_ben_left.gif" /></a> 
                        </div>
                        <div class="dep_ben_list fl">
                            <div class="ben_title"></div>
                            <select multiple="" size="3" id="userNameSelected1" name="teacher_group_ids[]" style="width:90px;height:150px;"></select>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center" class="pt20 pb20">
                    <input type="submit" value="保存" class="cursor b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 mr10" />
                    <input type="button" value="取消" onclick="api.close()" class="cursor b_a_n border_3 back_bgb w80 height32 fontc_FFF fonts_12" />
                </td>
            </tr>
        </tbody>
    </table>
    <?php
    $this->endWidget();
    ?>
</div>
<iframe src='' style="display:none" name='ajax-frame'></iframe>
<script>
                                $(function() {
                                    $(".select_t").bind("click", function() {
                                        $(".select_t_select").show();
                                    });
                                    var oUser = $('#user_select');
                                    $('.right').click(function() {
                                        var s = oUser.find('option:selected');
                                        $('#userNameSelected').find("option").attr("selected", false)
                                        s.appendTo($('#userNameSelected'));
                                        return false;
                                    });
                                    $('.left').click(function() {
                                        var s = $('#userNameSelected').find('option:selected');
                                        s.appendTo(oUser);
                                        return false;
                                    });


                                    var oUser1 = $('#userNameSelected');
                                    $('.right1').click(function() {
                                        var s = oUser1.find('option:selected');
                                        if (s.length > 1) {
                                            alert("组长只能选择一位");
                                            return false;
                                        }
                                        $('#userNameSelected1').find("option").attr("selected", false);
                                        $('#userNameSelected1').html(s.clone(true))
                                        return false;
                                    });
                                    $('.left1').click(function() {
                                        var s = $('#userNameSelected1').find('option:selected');
                                        s.remove();
                                        return false;
                                    });

                                });


                                //项目科目联动
                                function checkexam(val) {
                                    $.post('/question_collect/default/ajaxvalue', {id: val}, function(result) {
                                        var dataObj = eval("(" + result + ")");//转换为json对象
                                        var subjectstr = '';
                                        subjectstr += "<option value='0'>请选择</option>"
                                        $.each(dataObj, function(i, item) {
                                            subjectstr += "<option value='" + item.subject_id + "'>" + item.subject_name + "</option>"
                                        });
                                        $("#subject_id").html(subjectstr);
                                    });
                                }
                                function checksubject(val) {
                                    $.post('/question_collect/default/sujectquestions', {subject_id: val}, function(result) {
                                        var obj = $.parseJSON(result), newHtml = "";
                                        newHtml += "<option value='0'>请选择</option>"
                                        $.each(obj, function(i, item) {
                                            newHtml += "<option value='" + i + "'>" + item + "</option>"
                                        })
                                        $("#num_type").html(newHtml);
                                    });
                                    var exam_id = $('#exam_id').val();
                                    var parent_id = $('#user_select');
                                    $.get('/problem/question/questionteacher', {exam_id: exam_id, subject_id: val}, function(data) {
                                        parent_id.html(data);
                                    });
                                }
                                $("#add_form").submit(function() {
                                    $("#userNameSelected option,#userNameSelected1 option").attr("selected", true);
                                })
</script>
<script>
    $(function() {
        $.formValidator.initConfig({formID: "add_form", theme: "126", submitOnce: false,
            onError: function(msg, obj, errorlist) {
                $("#errorlist").empty();
                $.map(errorlist, function(msg) {
                    $("#errorlist").append("<li>" + msg + "</li>")
                });
                alert(msg);
            },
            ajaxPrompt: '有数据正在异步验证，请稍等...'
        });

        /*所属考试项目验证*/
        $("#exam_id").formValidator({
            onShowText: "",
            onShow: "",
            onFocus: "",
            onCorrect: "选择正确"
        }).inputValidator({
            min: 1,
            onError: "请选择考试项目"
        });

        /*所属科目验证*/
        $("#subject_id").formValidator({
            onShowText: "",
            onShow: "",
            onFocus: "",
            onCorrect: "选择正确"
        }).inputValidator({
            min: 1,
            onError: "请选择所属科目"
        });


        /*题号验证*/
        $("#num_id").formValidator({
            onShowText: "请输入题号",
            onShow: "",
            onFocus: "",
            onCorrect: "输入正确",
            leftTrim: true,
            rightTrim: true
        }).inputValidator({
            min: 1,
            onError: "题号不能为空"
        });

        /*所属科目验证*/
        $("#num_type").formValidator({
            onShowText: "",
            onShow: "",
            onFocus: "",
            onCorrect: "选择正确"
        }).inputValidator({
            min: 1,
            onError: "请选择题型"
        });

    })
</script>
<?php exit; ?>